package org.example.controller;

import com.baomidou.mybatisplus.extension.api.R;
import org.example.entity.User;
import org.example.service.BookFeignService;
import org.example.service.UserFeignService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author TonySong
 * @date 2024/6/27 0027
 * @time 11:46
 */
@RestController
@RequestMapping("/feign")
public class FeignController {

    @Resource
    private BookFeignService feignService;
    @Resource
    private UserFeignService userFeignService;

    @GetMapping("/listUser")
    public R listUser(){
        return this.userFeignService.getUsers();
    }

    @PostMapping("/addUser")
    public R addUser(@RequestBody User user){
        return this.userFeignService.addUser(user);
    }

    @GetMapping("/getBook/{id}")
    public R getUser(@PathVariable("id") Integer id){
        return this.userFeignService.getUser(id);
    }

    @PutMapping("/updateUser")
    public R updateUser(@RequestBody User user){
        return this.userFeignService.updateUser(user);
    }

    @DeleteMapping("/deleteUser/{id}")
    public R deleteUser(@PathVariable("id") Integer id){
        return this.userFeignService.deleteUser(id);
    }


    @GetMapping("/books")
    public R getBooks(){
        return feignService.getBooks();
    }




}
